package com.study.d1_stream;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        //map遍历方法一：键找值
        Map<String,Integer> map = new HashMap<>();
        map.put("C语言",20);
        map.put("Java",30);
        map.put("Go",30);
        map.put("CPP",35);
        System.out.println(map);
        Set<String> strings = map.keySet();
        for (String string : strings) {
            Integer value = map.get(string);
            System.out.println(string+"===>"+value);
        }
        System.out.println("=============");
        //方法二：键值对看成整体
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            System.out.println(entry.getKey() + "--->" + entry.getValue());
        }
        System.out.println("=============");
        //方法三 lambda表达式
        map.forEach((s,integer) -> System.out.println(s+"-=-=-=->>"+integer));

    }
}
